<template>
  <div class="app-container">
    <!-- Header 区域 -->
    <cart-header></cart-header>

    <!-- 商品 Item 项组件 -->
    <!-- 父传子
           子组件标签  属性名=值
           子组件内
               props:{
                属性名:{
                  type:类型
                  default:默认值
                  required:必传
                  validator:(value)=>{
                    return boolean 对值的验证
                  }
                }
               }  -->
    <cart-item
      v-for="item in $store.state.list"
      :key="item.id"
      :item="item"
    ></cart-item>

    <!-- Foote 区域 -->
    <cart-footer></cart-footer>
  </div>
</template>

<script>
import CartHeader from '@/components/cart-header.vue'
import CartFooter from '@/components/cart-footer.vue'
import CartItem from '@/components/cart-item.vue'
// import { cartGet } from '@/api/index.js'
export default {
  name: 'App',
  components: {
    CartHeader,
    CartFooter,
    CartItem
  },
  created () {
    // const res = await cartGet()
    // console.log(res)
    // 调用actions方法获取数据
    this.$store.dispatch('getList')
  }
}
</script>

<style lang="less" scoped>
.app-container {
  padding: 50px 0;
  font-size: 14px;
}
</style>
